package com.jacob;

import org.scijava.nativelib.JniExtractor;
import org.scijava.nativelib.NativeLibraryUtil;
import org.scijava.nativelib.NativeLoader;

import java.io.File;

/**
 * Created by zarra on 2017/1/25.
 */
public class NativeJarLoader {
    static boolean Loaded = false;
    public static void load(){
        try{
            if (Loaded == false) {
                JniExtractor jniExtractor = NativeLoader.getJniExtractor();
                NativeLibraryUtil.Architecture arch = NativeLibraryUtil.getArchitecture();
                String libPath = "lib/win64/";
                if (arch == NativeLibraryUtil.Architecture.WINDOWS_32){
                    libPath = "lib/win32/";
                }
                File lib = jniExtractor.extractJni(libPath, "jacob");
                System.load(lib.getAbsolutePath());
                Loaded = true;
            }
        }catch (Throwable e){
            e.printStackTrace();
        }
    }
}
